package com.txx.controller;

/**
 * @Author: zgc
 * @Date: 2021/5/20 10:55
 */

import com.txx.pojo.GoodsCategoryParam;
import com.txx.service.GoodsCategoryParamService;
import com.txx.vof.CategoryParamForm;
import com.txx.vor.SysResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import javax.websocket.server.PathParam;

/**
 * @Author: zgc
 * @Date: 2021/5/19 9:38
 */
@RestController
@CrossOrigin
@RequestMapping("/goodsCategoryParam")    //抽取公共的请求
public class GoodsCategoryParamController {

    @Autowired
    private GoodsCategoryParamService goodsCategoryParamService;

    @GetMapping("/list")
    public SysResult findParamByType(CategoryParamForm categoryParamForm)
    {
       return SysResult.success(goodsCategoryParamService.findParamByType(categoryParamForm));
    }

    /**
     * 实现商品分类新增操作
     * URL:  /itemCatParam/addItemCatParam
     * 参数: itemCatParam接收   注解格式要求
     * 返回值: SysResult对象
     */
    @PostMapping("/insert")
    public SysResult addItemCatParam(@RequestBody GoodsCategoryParam CategoryParam){

        return SysResult.success(goodsCategoryParamService.Insert(CategoryParam));
    }

    /**
     * 实现商品分类参数的更新
     * URL: /itemCatParam/updateItemCatParam
     * 参数: ItemCatParam参数
     * 返回值: SysResult对象
     */
    @PutMapping("/update")
    public SysResult updateItemCatParam(@RequestBody GoodsCategoryParam itemCatParam){

        return SysResult.success( goodsCategoryParamService.Update(itemCatParam));
    }

    /**
     * 商品分类参数删除insert
     * URL:/itemCatParam/deleteItemCatParamById
     * 参数: paramId=20
     * 返回值: SysResult对象
     */
    @DeleteMapping("/delete")
    public SysResult deleteItemCatParam(Integer id){

        return SysResult.success(goodsCategoryParamService.Delete(id));
    }
}
